package models.venue.room;

import goods.Goods;
import play.Logger;
import utils.ObjectUtil;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by hanbin on 17/5/4.
 */
public class RoomsVO {

    public Double allPrice;

    public Integer allSize;

    public List<RoomVO> roomVOList;

    public static RoomsVO createOrUpdateShopCartVO2(String goodsId) {
        List<RoomVO> roomVOList = new ArrayList<>();
        RoomsVO roomsVO = new RoomsVO();
        Double sPrice = 0d; // 总价

        String[] goodArr = goodsId.split(",");
        for (String good : goodArr){
            RoomVO roomVO = new RoomVO();

            Goods goods = Goods.getGoodsById(Long.valueOf(good));
            String name = goods.name;
            name = name.split("_")[3];
            roomVO.beginAtStr = name.substring(0,4)
                    + "." + name.substring(4,6)
                    + "." + name.substring(6,8)
                    + " " + name.substring(8,10)
                    + ":" + name.substring(10,12);

            roomVO.endAtStr = name.substring(0,4)
                    + "." + name.substring(4,6)
                    + "." + name.substring(6,8)
                    + " " + name.substring(12,14)
                    + ":" + name.substring(14);
            roomVO.price = new BigDecimal(goods.salePrice);

            sPrice += goods.salePrice;

            roomVO.goodsId = goods.id;
            roomVO.img = goods.img;

            Room room = Room.findById(goods.serialId);

            roomVO.roomName = room.roomName;

            roomVOList.add(roomVO);
        }

        // 订单总金额  商品金额综合
        roomsVO.allPrice = sPrice == null ? 0d : sPrice;
        roomsVO.allSize = roomVOList.size();
        roomsVO.roomVOList = roomVOList;

        return roomsVO;
    }

}
